package com.gexin.model.activity;

import com.gexin.model.activity.base.BaseGroupRule;

import java.util.*;

/**
 * 业务名称:  t_group_rule() 
 */
@SuppressWarnings("serial")
public class GroupRule extends BaseGroupRule<GroupRule> {
	public static final GroupRule dao = new GroupRule();

	public GroupRule range(int fansChildren){
		GroupRule first = GroupRule.dao.findFirst("select * from t_group_rule where number_of_people >= " + fansChildren
		+" and number_of_people<"+fansChildren);
		return first;
	}


	public List<GroupRule> getGroupRule(){
		List<GroupRule> all = dao.findAll();
		return all;
	}
	public List<GroupRule> oneGroupRule(String inviteeRelative1){
		List<GroupRule> all = dao.find("SELECT level FROM t_group_rule WHERE number_of_people<="+inviteeRelative1+" and number_of_people_max>"+inviteeRelative1+"");
		return all;
	}

	public static Boolean deletGroupRule(String id) {
		return GroupRule.dao.deleteById(id);
	}
	public GroupRule getGroupRule(String level){
		GroupRule first = GroupRule.dao.findFirst("select * from t_group_rule where level="+level);
		return first;

	}

	public static Boolean insertGroupRule(Integer numberOfPeople, Integer multiple, Integer level,Integer balance,Integer type,Integer number_of_people_max){
		GroupRule groupRule = new GroupRule();
		groupRule.setId(String.valueOf(UUID.randomUUID()));
		groupRule.setNumberOfPeople(numberOfPeople);
		groupRule.setMultiple(multiple);
		groupRule.setLevel(level);
		groupRule.setBalance(balance);
		groupRule.setType(type);
		groupRule.setNumberOfPeopleMax(number_of_people_max);
		Boolean flag = false;
		flag = groupRule.save();
		return flag;
	}

}
